<template>
	<view class="title">
		<wd-icon style="color: white" name="thin-arrow-left" size="22px" @click="huitui"></wd-icon>
		<wd-search style="width: 90vw; background-color: black" v-model="keyword" hide-cancel></wd-search>
		<text style="color: wheat; width: 2rem; margin-right: 10px" @click="sousuo">搜索</text>
	</view>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue';
import { useToast } from '@/uni_modules/wot-design-uni';
import { sousuodata } from '../../api/api';
const toast = useToast();
const props = defineProps<{ serach: any; item: string }>();
const keyword = ref('');

const sousuo = async () => {
	if (keyword.value != '') {
		props.serach(keyword.value);
		let data = await sousuodata({ name: keyword.value });
		if (data.code == 200) {
			console.log(data.video);
			sessionStorage.setItem('video', JSON.stringify(data.video));
			uni.redirectTo({
				url: `/pages/serach_outcome/serach_outcome`
			});
		}
	} else {
		toast.error({
			iconClass: 'star',
			msg: '不能搜索空哦~'
		});
	}
};

const huitui = () => {
	uni.navigateBack({
		delta: 1
	});
};
</script>

<style scoped lang="scss">
view {
	background-color: black;
}
.title {
	width: 100vw;
	display: flex;
	background-color: black;
	flex-direction: row;
	justify-content: space-between;
	align-items: center;
}
</style>
